package com.bootdo.system.service.impl;

import com.bootdo.common.dao.FileDao;
import com.bootdo.common.utils.StringUtils;
import com.bootdo.system.dao.CompanyDao;
import com.bootdo.system.domain.CompanyDO;
import com.bootdo.system.service.CompanyService;
import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;



@Service
public class CompanyServiceImpl implements CompanyService {

	@Autowired
	private FileDao fileDao;

	@Autowired
	private CompanyDao companyDao;
	
	@Override
	public CompanyDO get(Long id){
		return companyDao.get(id);
	}
	
	@Override
	public List<CompanyDO> list(Map<String, Object> map){
		List<CompanyDO> list= companyDao.list(map);
		if(!CollectionUtils.isEmpty(list)) {
			Map<String,Object> map1 = null;
			for(CompanyDO data : list) {
				if(StringUtils.isNotEmpty(data.getAttachId())) {
					map1 = new HashMap<String, Object>();
					map1.put("attachId",data.getAttachId());
					data.setFilePathList(fileDao.list(map1));
				}
			}
		}
		return list;
	}
	
	@Override
	public int count(Map<String, Object> map){
		return companyDao.count(map);
	}
	
	@Override
	public int save(CompanyDO company){
		return companyDao.save(company);
	}
	
	@Override
	public int update(CompanyDO company){
		return companyDao.update(company);
	}
	
	@Override
	public int remove(Long id){
		return companyDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return companyDao.batchRemove(ids);
	}
	
}
